package com.xmg.boot.demo.bootlesson1.user.controller;

import com.xmg.boot.demo.bootlesson1.user.annotation.StartSwaggerScan;
import com.xmg.boot.demo.bootlesson1.user.entity.pojo.Student;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *@Author: ma
 *@CreateTime: 2023-11-23
 *@Description: Rabbit消息队列
 *@Version: 1.0
 */

@StartSwaggerScan
@RestController
public class AmqpController {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @ApiOperation(value = "发送字符串")
    @GetMapping("/sendString")
    public String sendString(){
        amqpTemplate.convertAndSend("hello","hello mq");
        return "OK";
    }
    @ApiOperation(value = "发送对象")
    @GetMapping("/sendObject")
    public String sendObject(){
        Student stu=new Student();
        stu.setId(100);
        stu.setStuName("张三");
        amqpTemplate.convertAndSend("hello",stu);
        return "OK";
    }
}
